import 'package:flutter/material.dart';

void main(List<String> args) {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '我的',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: const Text('我的'),
        ),
        body: MyBody(),
      ),
    );
  }
}

class MyBody extends StatelessWidget {
  const MyBody({super.key});

  @override
  Widget build(BuildContext context) {
    // return RatioDemo();
    return CardList();
  }
}

class RatioDemo extends StatelessWidget {
  const RatioDemo({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.red,
      child: AspectRatio(
        // 宽高比
        aspectRatio: 16 / 9,
        child: Container(
          color: Colors.green,
        ),
      ),
    );
  }
}

class CardList extends StatelessWidget {
  const CardList({super.key});

  @override
  Widget build(BuildContext context) {
    return ListView(
      children: [
        // 卡片可以用来展示明信片的样式
        Card(
          // 外边距
          margin: const EdgeInsets.all(4),
          // 背景颜色
          color: const Color.fromARGB(255, 255, 180, 209),
          // 阴影的深度
          elevation: 5,
          // 卡片的形状，RoundedRectangleBorder为圆角
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(8),
          ),
          child: Column(
            children: [
              ListTile(
                // 圆形图片
                leading: CircleAvatar(
                  // 半径大小
                  radius: 23,
                  backgroundImage: AssetImage("images/2.0x/热巴1.jpg"),
                ),
                title: Text('迪丽热巴'),
                subtitle: Text('123456@qq.com'),
              ),
              Divider(),
              ListTile(
                title: Text("telephone: 110"),
              )
            ],
          ),
        ),
        Card(
          // 外边距
          margin: const EdgeInsets.all(4),
          // 背景颜色
          color: const Color.fromARGB(255, 226, 211, 255),
          // 阴影的深度
          elevation: 5,
          // 卡片的形状，RoundedRectangleBorder为圆角
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(8),
          ),
          child: Column(
            children: [
              AspectRatio(
                aspectRatio: 16 / 9,
                child: Image.network(
                  "https://k.sinaimg.cn/n/sinakd20117/0/w800h800/20240127/889b-4c8a7876ebe98e4d619cdaf43fceea7c.jpg/w700d1q75cms.jpg",
                  fit: BoxFit.cover,
                ),
              ),
              SizedBox(
                height: 10,
              ),
              ListTile(
                leading: ClipOval(
                  child: Image.network(
                    "https://k.sinaimg.cn/n/sinakd20117/0/w800h800/20240127/889b-4c8a7876ebe98e4d619cdaf43fceea7c.jpg/w700d1q75cms.jpg",
                    fit: BoxFit.cover,
                  ),
                ),
                title: Text('蜡笔小新'),
              ),
              SizedBox(
                height: 10,
              ),
            ],
          ),
        )
      ],
    );
  }
}
